﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlServerCe;

namespace ProjectoPV_ESW.Account.EmentaV2
{
    public partial class ListagemDePratosEscolhidosForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DateTime data = new DateTime();
            try
            {
                data = (DateTime)Session["DataEmenta"];
            }
            catch( Exception exc)
            {
                this.Label1.Text = exc.Message;
            }

            String list = "";
            string connectionString = ConfigurationManager.ConnectionStrings["JardimEntitiesString"].ConnectionString;
            SqlCeConnection conn= new SqlCeConnection(connectionString);

            string command = "SELECT * FROM [Crianca],[EscolhaPratoV2]";//,[EscolhaPratoV2]) WHERE @Crianca_CriancaId=@CriancaId";
            // AND EscolhaPratoV2.dia=" + data.Day + " AND EscolhaPratoV2.mes=" + data.Month + " AND EscolhaPratoV2.ano=" + data.Year+")";
            SqlCeCommand cmd = new SqlCeCommand(command, conn);
            SqlCeDataReader reader;

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    list += "Criança: " + (string)reader["Nome"] + "   ";
                    list += "Prato Escolhido: " + (string)reader["Prato"] + "\n";
                }
                TextBox1.Text = list;
            }
            catch (Exception exc)
            {
                Label1.Text = exc.Message+" "+ exc.Source;

            }
            finally
            {
                conn.Close();
            }


        }
    }
}